package pl.edu.pw.elka.GIS.graph;

import java.util.ArrayList;
import java.util.Collection;

public class Vertex {
	private int id;
	private int color;
	private int degree;
	private ArrayList<Integer> edge = new ArrayList<Integer>();
	private boolean visited;
	private int subGraphId;

	public ArrayList<Integer> getEdge() {
		return edge;
	}

	
	public void recurSubGraph(int min,int max){
		for(Vertex v : this.neighbours){
			if(v.getSubGraphId() == 0 && (v.getColor() == min || v.getColor() == max)){
				v.setSubGraphId(this.getSubGraphId());
				v.recurSubGraph(min,max);
			}
		}
	}
	
	
	public void lowerDegree() {
		this.degree--;
	}

	private Collection<Vertex> neighbours = new ArrayList<Vertex>();

	public Vertex(int id) {
		setKolor(0);
		setSubGraphId(0);
		this.id = id;
	}

	public void addNeighbour(Vertex neighbour) {
		neighbours.add(neighbour);
		degree++;
		edge.add(neighbour.getId());
	}

	public void removeNeighbour(Vertex neighbour) {
		neighbours.remove(neighbour);
	}

	public boolean hasNeighbour(Vertex neighbour) {
		return neighbours.contains(neighbour);
	}

	public int getColor() {
		return color;
	}

	public void setColor(int color) {
		this.color = color;
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setKolor(int kolor) {
		this.color = kolor;
	}

	public int getKolor() {
		return color;
	}

	public void setNumber(int number) {
		this.id = number;
	}

	public int getNumber() {
		return id;
	}

	public void setDegree(int d) {
		this.degree = d;
	}
	public int getDegree() {
		return degree;
	}

	public void setSubGraphId(int subGraphId) {
		this.subGraphId = subGraphId;
	}

	public int getSubGraphId() {
		return subGraphId;
	}

	public void setEdge(ArrayList<Integer> edge) {
		this.edge = edge;
	}

	public void setVisited(boolean visited) {
		this.visited = visited;
	}

	public boolean isVisited() {
		return visited;
	}
}
